package com.ogawa.base.download;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.ogawa.base.R;
import com.ogawa.base.network.bean.BeanUpdata;


/**
 * 更新
 * Created by fhb on 2016/4/8.
 *
 */
public class AlertDialogUpdata extends Dialog {
    private OnDialogListener mClickListenerCancel,mClickListenerOk;
    private TextView mTvContent1;
    private TextView mBtnCancel,mBtnOk;

    private TextView mTvTitle;
    private BeanUpdata mBean;

    //定义回调事件，用于dialog的点击事件
    public interface OnDialogListener{
             void onClick();
    }


    /**
     * 对话框
     * @param context


     * @param ClickCancel  取消按钮事件
     * @param ClickOk  确定按钮事件
     */
    public AlertDialogUpdata(Context context, BeanUpdata bean, OnDialogListener ClickCancel, OnDialogListener ClickOk) {
            super(context, R.style.BaseDialog);

            mClickListenerCancel = ClickCancel;
            mClickListenerOk = ClickOk;
            mBean = bean;
    }

   
    @Override
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            	//去掉Title
            AlertDialogUpdata.this.requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.dialog_updata);
            //内容1
            mTvContent1 = (TextView)findViewById(R.id.updata_content1);
            mTvContent1.setText(mBean.getNotice()+"");
             mTvTitle = (TextView)findViewById(R.id.updata_title) ;


            //取消按钮
             mBtnCancel = (TextView) findViewById(R.id.do_cancle);
                mBtnCancel.setOnClickListener(clickListener);
                if(mBean.getIsforce()==1){
                    mBtnCancel.setText("退出");
                }
            //确定按钮
              mBtnOk = (TextView) findViewById(R.id.do_updata);
                mBtnOk.setOnClickListener(clickListener);
    }
    private View.OnClickListener clickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int i = v.getId();
                if (i == R.id.do_cancle) {
                    if (mClickListenerCancel != null)
                        mClickListenerCancel.onClick();
                    AlertDialogUpdata.this.dismiss();

                } else if (i == R.id.do_updata) {
                    if (mClickListenerOk != null)
                        mClickListenerOk.onClick();
                    AlertDialogUpdata.this.dismiss();

                }
            }
    };
}
